/*
 *  CEScrollBar.h
 *  LID Library
 *
 *  Created by Alexander Trutchenko on 09/11/11.
 *  Copyright 2011 League of Independent Developers. All rights reserved.
 *
 */

#ifndef __CE_ScrollBar_h__
#define __CE_ScrollBar_h__


#include "cocos2dx_extentions/nodes/CENodeRGBA.h"

namespace cocosext {

#define LTT_SCROLL_BAR_FADE_IN_TIME 0.2f
#define LTT_SCROLL_BAR_FADE_OUT_TIME 0.5f

/////////////////////////////////////////////////////
//
/** CEScrollBar 
* Base is vertical scrollbar. Horizontal scrollbar is rotated
*/
/////////////////////////////////////////////////////

class CEScrollBar : public CENodeRGBA
{
protected:
	float _barSize;
	float _barPosition;

protected:
	CEScrollBar(): _barSize(1.f), _barPosition(0.f) {;}

	virtual bool init()
	{
		if (!CENodeRGBA::init())
			return false;
		return true;
	}

public:
    virtual ~CEScrollBar() {;}

public:
	virtual void setBarSize(float barSize) { _barSize = barSize; } // 0..1
	virtual void setBarPosition(float position) 
	{ 
		if (position < 0.f)
			_barPosition = 0.f;
		else if (position > 1.f)
			position = 1.f;
		else
			_barPosition = position; }  // 0..1, position from top or left

	virtual void forceHide() { this->setIsVisible(false); }
	virtual void show() { this->setIsVisible(true); }
	virtual void hide() { this->setIsVisible(false); }

//Cocos2d interface

}; //CEScrollBar

/////////////////////////////////////////////////////
//
/** CEScrollBarColor 
* Colored scrollbar
*/
/////////////////////////////////////////////////////

class CEScrollBarColor : public CEScrollBar
{
	cocos2d::ccColor4B _scrollBarBkColor;
	cocos2d::ccColor4B _scrollBarColor;

protected:
	CEScrollBarColor(const cocos2d::ccColor4B& scrollBarBkColor, const cocos2d::ccColor4B& scrollBarColor)
		: _scrollBarBkColor(scrollBarBkColor)
		, _scrollBarColor(scrollBarColor) {;}

    virtual bool init();

public:
    virtual ~CEScrollBarColor() {;}

	    /* Static constructor */
    static CEScrollBarColor* node(const cocos2d::ccColor4B& scrollBarBkColor, const cocos2d::ccColor4B& scrollBarColor);

	virtual void show();
	virtual void hide();
	virtual void forceHide() { this->setIsVisible(false); this->setOpacity(0); }

public:

//Cocos2d interface
	virtual void draw(void);

}; //CEScrollBar

}; // end namespace cocosext

#endif // __CE_ScrollBar_h__
